package com.lujieni.provider.controller;

import com.lujieni.provider.po.StudentPO;
import com.lujieni.provider.service.IStudentService;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.concurrent.TimeUnit;

@RestController
@Slf4j
public class HelloController {


    @Value("${spring.cloud.client.ip-address}")
    private String ip;

    @Autowired
    private IStudentService studentService;

    @GetMapping("/hello")
    public String sayHello(HttpServletRequest request){
        return ip+":::"+request.getHeader("token");
    }

    @GetMapping("/bye")
    public List<StudentPO> sayBye(HttpServletRequest request) throws InterruptedException {
        log.info("HelloController:sayBye function start");
        //TimeUnit.SECONDS.sleep(2);
        //int i = 5 / 0;
        return studentService.findAllStudent();
    }

}
